<?php
namespace Auth;

class Auth
{
    const SESSION_NAME = 'auth';
    private static $user;

    /**
     * 登录
     *
     * @return void
     */
    public static function login($user)
    {
        self::$user = $user;
        session(self::SESSION_NAME, $user);

    }

    public static function loginUsingId($uid)
    {
         $user = D('AdminUser')->find($uid);
         self::login($user);
    }

    public static function hasLogined()
    {
        $user = session(self::SESSION_NAME);
        return !empty($user);
    }

    /**
     * 注销
     *
     * @return void
     */
    public static function signout()
    {

    }

    /**
     * 返回当前登录用户
     *
     * @return array
     */
    public static function user()
    {
        return self::hasLogined() ? session(self::SESSION_NAME) : false;
    }
}